/***************************************************************************
 *            imprimir.h
 *
 *  Qua julho 13 07:56:42 2011
 *  Copyright  2011  Alcione Ferreira
 *  <user@host>
 ****************************************************************************/
#include <bibliotecas.h>

#ifndef __IMPRESSAO_H__
#define __IMPRESSAO_H__ 1

#include <pangomm.h>

/**
 * Classe utilizada para impressão dos recibos
 */
class PrintFormOperation : public Gtk::PrintOperation
	{
 	public:
		/** Método utilizado para instanciar a classe.*/
	  	static Glib::RefPtr<PrintFormOperation> create();
		/** Método destrutor da classe*/
	  	virtual ~PrintFormOperation();
		/** Método utilizado para setar o corpo do texto a ser impresso.*/
	  	void set_corpo(int, string, int);

 	protected:
		/** Método construtor da classe*/
  		PrintFormOperation();

	  	/** PrintOperation default signal handler overrides:*/
	  	virtual void on_begin_print(const Glib::RefPtr<Gtk::PrintContext>& context);
		/** PrintOperation default signal handler overrides:*/
	  	virtual void on_draw_page(const Glib::RefPtr<Gtk::PrintContext>& context, int page_nr);

	  	Glib::ustring m_cabecalho;/**<Atributo para guardar o texto do cabeçalho do recibo*/
	  	Glib::ustring m_corpo;/**<Atributo para guardar o texto do corpo do recibo*/
		Glib::ustring m_rodape;/**<Atributo para guardar o texto do rodapé do recibo*/
		Glib::ustring data;/**<Atributo para guardar a data do recibo*/
  		Glib::RefPtr<Pango::Layout> Formulario;/**<Ponteiro para o Layout do Formulário*/
		
  		std::vector<int> QuebraPagina; /**< line numbers where a page break occurs */

	private:
		double largura;/**<*/
		double altura;/**<*/
		/** */
		void set_cabecalho();
		/** */
		void set_rodape();
		bool s_issqn;
	};
/**
 *
 */
class IMPRIMIR: public Gtk::Window
	{
	public:
		/** */
  		IMPRIMIR(BANCOPG *,int,string,int,bool impresso=false);
		/** */
  		virtual ~IMPRIMIR();
		/** */
		void corpo(const Glib::ustring& );

	protected:
		Glib::ustring cabecalho_text;/**<*/
		Glib::ustring corpo_text;/**<*/
		Glib::ustring rodape_text;/**<*/
		/** */
  		void print_or_preview(Gtk::PrintOperationAction print_action);
		/** */
		void Imprimir_Preview();
		/**
		  * PrintOperation signal handlers.\n
		  * We handle these so can get necessary information to update the UI or print settings.\n
		  * Our derived PrintOperation class also overrides some default signal handlers.\n
		  */
	  	void on_printoperation_status_changed(const Glib::RefPtr<PrintFormOperation>& operation);
		/**
		  * PrintOperation signal handlers.\n
		  * We handle these so can get necessary information to update the UI or print settings.\n
		  * Our derived PrintOperation class also overrides some default signal handlers.\n
		  */
	  	void on_printoperation_done(Gtk::PrintOperationResult result, const Glib::RefPtr<PrintFormOperation>& operation);

	  	/** 
		 * Action signal handlers:
		 */
	  	void on_menu_file_new();
		/** 
		 * Action signal handlers:
		 */
	  	void Imprimir_Config();
	  	/** */
	  	void Imprimir();
		/** */
	  	void fechar();
		/** */
		void tags_create();
		/** */
		void gerar_texto();

	  	Glib::RefPtr<Gtk::PageSetup> SetupPagina; /**<Printing-related objects*/
	  	Glib::RefPtr<Gtk::PrintSettings> ConfImpress;/**<Printing-related objects*/

		Glib::RefPtr<Pango::Layout> Formulario;/**<*/
  		std::vector<int> QuebraPagina; /**< line numbers where a page break occurs*/

		Gtk::VBox Box_Principal;/**<*/
		Gtk::VBox Box_Conteudo/**<*/;
		Gtk::VBox Box_Menu;/**<*/

		Gtk::Toolbar tb_imprimir;/**<*/
		Gtk::ToolButton b_imprimir;/**<*/
		Gtk::ToolButton b_preview;/**<*/
		Gtk::ToolButton b_setup;/**<*/
		Gtk::ToolButton b_fechar;/**<*/
		Gtk::SeparatorToolItem b_separador;/**<*/

		Gtk::ScrolledWindow SVisualiza;/**<*/
		Gtk::TextView TVisualiza;/**<*/
		Glib::RefPtr<Gtk::TextBuffer> PVisualiza;/**<*/
		Gtk::TextIter iter;/**<*/
		Gtk::TextIter inicio;/**<*/
		Gtk::TextIter final;/**<*/
		Glib::RefPtr<Gtk::TextTag> tags;/**<*/
			
		Glib::RefPtr<Gdk::Pixbuf> pixbuf;/**<*/

	private:
		BANCOPG *conexao;/**<*/
		int tipo;/**<*/
		int recibo;/**<*/
		string data;/**<*/
		bool s_issqn;/**<*/
	};

#endif /*__IMPRESSAO_H__*/